export default {
    namespaced: true,
    state: {
        isLogin: sessionStorage.getItem('isLogin') || false,
        username: sessionStorage.getItem('isLogin') || 'xxx'
    },
    mutations: {
        login(state) {
            state.isLogin = true
            sessionStorage.setItem('isLogin', true)
        },
        logout(state) {
            state.isLogin = false
            sessionStorage.setItem('isLogin', false)
        },
        setUsername(state,uearname){
            state.uearname = uearname
            sessionStorage.setItem('uearname', uearname)
        }
        
    },
    actions: {
        login({commit},uearname){
            // 要在内部使用用commit
            commit('login')
            commit('setUsername',uearname)
        }
    },
}

// 有存储插件 vuepersist